home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / xyos2shl.zip / LISTOBJS.CMD < prev    next >
OS/2 REXX Batch file  |  1996-06-03  |  5KB  |  196 lines

  1. /****
  2.  LISTOBJS.CMD v1.0c  R.J.Holmgren  6/3/96
  3.  Command "LISTOBJS ?" for Help
  4. ****/
  5.  
  6. if arg(1)='?'|arg(1)='-?'|arg(1)='/?'|translate(arg(1))='HELP' then do
  7.   say
  8.   say 'LISTOBJS.CMD v1.0c  --  List all Object Titles and IDs in WorkPlace Shell'
  9.   say '            R.J.Holmgren  6/3/96'
  10.   say
  11.   say 'Usage:'
  12.   say '-----'
  13.   say 'listobjs          - list all Titles + ObjectIDs + Handles'
  14.   say 'listobjs Title_mask      - case INsensitive search for Titles matching'
  15.   say '                substring, e.g. "listobjs window"'
  16.   say 'listobjs IDx          - case sEnSiTiVe search for ObjectIDs matching'
  17.   say '                substring x, e.g. "listobjs IDREX"'
  18.   say '                N.B.:   Do NOT use "<>" chars in sub$ x'
  19.   say '                    The "ID" prefix must be UPPERCASE'
  20.   say 'listobjs /np          - scroll output (No Paging)'
  21.   say 'listobjs /np > filename      - redirect output to a file'
  22.   say 'listobjs ?|/?|-?|help      - this screen'
  23.   exit
  24.   end
  25.  
  26. args=0 /* Default list */
  27. allhandles0=''
  28. allhandles1=''
  29. allhandles2=''
  30. command=''
  31. np=0
  32. if arg(1)\='' then do
  33.   args=2 /* Get $ in titles */
  34.   command=strip(arg(1))
  35.   if pos('ID',command)=1 then do
  36.     args=1 /* Get $ in ObjectIDs */
  37.     command=substr(command,3)
  38.     end
  39.   if pos('/NP',translate(command))>0 then do
  40.     if translate(command)="/NP" then args=0
  41.     np=1
  42.     end
  43.   if command='' then args=0
  44.   if args=2 then command=translate(command)
  45.   end
  46.  
  47. say " LISTOBJS.CMD v1.0c - List OS/2 Object Titles and IDs - R.J.Holmgren"
  48. say ' Command "LISTOBJS ?" for Help         'date(L)||' at '||time(N)
  49. say
  50. call charout ," Getting Processes and Titles from OS2.INI (takes awhile) . . . "
  51.  
  52. if RxFuncQuery("SysLoadFuncs") then do
  53.   call RxFuncAdd "SysLoadFuncs", "REXXUTIL","SysLoadFuncs"
  54.   call SysLoadFuncs
  55.   end
  56.  
  57. call SysIni 'USER', 'PM_Workplace:Location', 'ALL:', 'objid.'
  58.  
  59. objects.='undefined object'
  60. do i=1 to objid.0
  61.   handle=SysIni('USER', 'PM_Workplace:Location', objid.i)
  62.   handle=C2X(Reverse(Left(handle,2)))
  63.   handle=strip(handle,'L','0')
  64.   id=objid.i
  65.   objects.id=handle
  66.   objects.handle=id
  67.   end
  68.  
  69. x=0
  70. ProcTitle.1=''
  71.  
  72. do i=1 to objid.0 
  73.   id=objid.i
  74.   handle=objects.id
  75.  
  76.   stuff=SysIni('USER','PM_Abstract:FldrContent',handle)
  77.   do while stuff\=''
  78.     parse var stuff handle 3 5 stuff
  79.     handle=C2X(Reverse(left(handle,2)))
  80.     handle=strip(handle,'L','0')
  81.     val=SysIni('USER','PM_Abstract:Objects',handle)
  82.     if val='ERROR:' then do 
  83.       call addit
  84.       iterate
  85.       end
  86.     val=translate(val,'^','0A'x) /* remove carriage returns */
  87.     val=translate(val,' ','!@><#$%^&*_+-=?')
  88. /*     val=translate(val,'','  ') */
  89.     val=translate(val,Copies('00'x,256),XRange('7F'x,'1F'x)) /* unprintable chars become '00'x */
  90.     val=translate(translate(val,'FF'x,' '),' ','00'x)
  91.     if objects.handle\='' THEN
  92.       objID=objects.handle
  93.     else
  94.       objID=handle
  95.     parse var val 'WPAbstract' objTitle 'WPObject'
  96.     objTitle=strip(translate(objTitle,' ','FF'x))
  97.     objTitle=strip(left(objTitle,Length(objTitle)-1))
  98.     objTitle1=left(objTitle,32)
  99.     call doit
  100.     end
  101.   end
  102.  
  103. call DumpDupes
  104.  
  105. say
  106. call charout ," Sorting "||x||" Objects . . . "
  107.  
  108. y=1
  109. do while x>1
  110.   SortedProc.y=ProcTitle.1
  111.   z=1
  112.   do i=2 to x
  113.     if ProcTitle.i<SortedProc.y then do
  114.       SortedProc.y=ProcTitle.i
  115.       z=i
  116.       end
  117.     end
  118.   ProcTitle.z=ProcTitle.x
  119.   x=x-1
  120.   y=y+1
  121.   end
  122. SortedProc.y=ProcTitle.x
  123.  
  124. if np=0 then call SysCls
  125. say
  126. say "Process Title             <ObjectID> and Handle"
  127. say "-------------             ---------------------"
  128. if y=0 then do
  129.   y=1
  130.   SortedProc.1='None found'
  131.   end
  132. do i=1 to y
  133.   if args=0 then say SortedProc.i
  134.   if args=1 then do
  135.     z=''
  136.     if pos('<',SortedProc.i)=34 then do
  137.       z=right(SortedProc.i,length(SortedProc.i)-34)
  138.       if pos('>',z)>0 then do
  139.         z=left(z,pos('>',z)-1)
  140.         if pos(command,z)>0 then say SortedProc.i
  141.         end
  142.       end
  143.     end
  144.   if args=2 then do
  145.     z=left(translate(SortedProc.i),32)
  146.     if pos(command,z)>0 then say SortedProc.i
  147.     end
  148.   parse value SysCurPos() with row col
  149.   if row=24 then call HitKey
  150.   end
  151.  
  152. call HitKey
  153. exit
  154.  
  155. DOIT:
  156. x=x+1
  157. ProcTitle.x=objTitle1' 'objID'    'handle
  158. allhandles0=allhandles0||"+"||handle
  159. call addit
  160. RETURN
  161.  
  162. ADDIT:
  163. allhandles2=allhandles0||allhandles1
  164. if pos(objects.id,allhandles2)<1 then do
  165.   x=x+1
  166.   ProcTitle.x='Folder:                          'id'    'objects.id
  167.   allhandles1=allhandles1||"+"||objects.id
  168.   end
  169. RETURN
  170.  
  171. DUMPDUPES:
  172. zap=''
  173. tab=0
  174. do i=1 to x
  175.   if pos('Folder:  ',ProcTitle.i)=1 then do
  176.     tab=pos('    ',ProcTitle.i)
  177.     zap=right(ProcTitle.i,length(ProcTitle.i)-tab)
  178.     if pos(zap,AllHandles0)>0 then do
  179.       if i<x then ProcTitle.i=ProcTitle.x
  180.       x=x-1
  181.       i=i-1
  182.       end
  183.     end
  184.   if i=x then leave
  185.   end
  186. RETURN
  187.  
  188. HITKEY:
  189. if np=0 then do
  190.   call charout ,"        Hit key to continue . . . "
  191.   call SysGetKey 'noecho'
  192.   call SysCls
  193.   end
  194. RETURN
  195.  
  196.